home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
public
/
bit
/
src
/
ulib
/
polybounds.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
965b
|
48 lines
/***********************************************************************
* $Id: polybounds.c,v 0.80 1994/02/24 09:48:11 zhao Exp $
*
*. Copyright(c) 1993,1994 by T.C. Zhao
* All rights reserved.
*.
*
***********************************************************************/
#if !defined(lint) && defined(F_ID)
char *id_pb = "$Id: polybounds.c,v 0.80 1994/02/24 09:48:11 zhao Exp $";
#endif
#include "ulib.h"
Rect_t *
spoly_bounds(short *x, short *y, int n)
{
static Rect_t brect[5];
static int nb;
Rect_t *b = brect + nb++;
int xmin = x[0], xmax = x[0];
int ymin = y[0], ymax = y[0];
int i;
for (i = 1; i < n; i++)
{
if (x[i] < xmin)
xmin = x[i];
else if (x[i] > xmax)
xmax = x[i];
if (y[i] < ymin)
ymin = y[i];
else if (y[i] > ymax)
ymax = y[i];
}
b->x = xmin;
b->y = ymin;
b->w = xmax - xmin + 1;
b->h = ymax - ymin + 1;
nb %= 5;
return b;
}